<!DOCTYPE html>
<html>
	<head>
		<title>手机注册</title>
		<meta charset="utf-8">
		<meta name="Description" content="" />
		<meta name="Keywords" content="" />
		<meta name="format-detection" content="telephone=no, email=no" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
		<meta name="applicable-device" content="mobile" />
		<meta name="apple-mobile-web-app-title" content="" />
		<!-- 添加到主屏后的标题（iOS 6 新增） -->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 是否启用 WebApp 全屏模式 -->
		<meta name="HandheldFriendly" content="true" />
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="author" content="Jack" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script type="text/javascript" src="__STATIC__/module/index/js/flexible.js"></script>
		<link rel="stylesheet" href="__STATIC__/module/index/css/main.css" />
		<link rel="stylesheet" href="__STATIC__/module/index/css/layer/layer.css" />
	</head>
	<body>
		{if $info.is == 2}
			<div class="header">
				<div class="header-cen">
					<div class="fpx"><img src="__STATIC__/module/index/images/left.png" alt="" class="left-icon"/></div>
					<div class="fpx fpx2 active">企业注册</div>
					<div class="fpx fpx3"><a href="{:url('login/register',array('is'=>1,'tjid'=>$info['tjid']))}" style="color:green">个人注册</a></div>
				</div>				
			</div>
			<div class="logo-div">
				<img src="__STATIC__/module/index/images/logo1.png" alt="" class="logo-my"/>
				<div class="logo-top-text">诸葛聘企业端</div>
			</div>
		{else}
			<div class="header">
				<div class="header-cen">
					<div class="fpx"><img src="__STATIC__/module/index/images/left.png" alt="" class="left-icon"/></div>
					<div class="fpx fpx2 active">个人注册</div>
					<div class="fpx fpx3"><a href="{:url('login/register',array('is'=>2,'tjid'=>$info['tjid']))}" style="color:green">企业注册</a></div>
				</div>			
			</div>
			<div class="logo-div">
				<img src="__STATIC__/module/index/images/logo1.png" alt="" class="logo-my"/>
				<div class="logo-top-text">诸葛聘个人端</div>
			</div>
		{/if}
		<div class="info-max margin-top">
			<div class="info-max-cen border-bottom">				
				<div class="left-item">手机号 <span class="des">*</span></div>
				<div class="right-item"><input type="number" placeholder="作为登录账号"  id="reg-phone"/></div>				
			</div>
			
			<div class="info-max-cen postion">				
				<div class="left-item">验证码 <span class="des">*</span></div>
				<div class="right-item"><input type="text" placeholder="请输入验证码" id="reg-code"/></div>
				<div class="code-div verify"><button class="get-code" onclick="code()">获取验证码</button></div>
			</div>
		</div>
		
		<div class="info-max margin-top">
			<div class="info-max-cen border-bottom">				
				<div class="left-item">登录密码 <span class="des">*</span></div>
				<div class="right-item"><input type="password" placeholder="请输入密码" id="reg-pwd1"/></div>				
			</div>
			
			<div class="info-max-cen postion">				
				<div class="left-item">确认密码 <span class="des">*</span></div>
				<div class="right-item"><input type="password" placeholder="请再次输入" id="reg-pwd2"/></div>	
			</div>
		</div>
		
		
		
		<div class="info-max margin-top">
			<div class="info-max-cen">				
				<div class="left-item">{if $info.is == 1}姓名{else/}公司名称{/if} <span class="des">*</span></div>
				<div class="right-item"><input type="text" placeholder="请输入{if $info.is == 1}姓名{else}公司名称{/if}" id="reg-name"/></div>				
			</div>						
		</div>
		
		<!-- <div class="privacy">
			<img src="__STATIC__/module/index/images/chake1.png" alt="" class="chead"/> 注册表示同意 <a href="" class="privacy-a">隐私政策</a>
		</div> -->
		
		
		<button class="register-btn" onclick="register()">注册</button>
		
	</body>
	<script src="__STATIC__/module/index/js/jquery.min.js"></script>
	<script src="__STATIC__/module/index/js/layer/layer.js"></script>
	<script src="__STATIC__/module/index/js/api_url.js"></script>
	<script src="__STATIC__/module/index/js/md5/md5.js"></script>
	<script src="__STATIC__/module/index/js/md5/access.js"></script>	
	<script type="text/javascript">
		function register(){
			var reg = /^1(3|4|5|6|7|8|9)\d{9}$/;
			if($.trim($('#reg-phone').val()) == ''){
				layer.msg('请输入手机号');
				return false;
			}						
            if(!reg.test($.trim($('#reg-phone').val()))) {
            	layer.msg('请正确填写手机号');
                 return false;
            }
            if($.trim($('#reg-phone').val()) != ''&&reg.test($.trim($('#reg-phone').val()))){
            	$('#register-phone').hide().html('');            	
            }
            
            if($.trim($('#reg-code').val()) == ''){
            	layer.msg('请输入验证码');
				return false;
			}else{
				$('#register-code').hide().html('');
				
			}           
            if($.trim($('#reg-pwd1').val()) == ''){
            	layer.msg('请填写密码');
                    return false;
            }
            if($.trim($('#reg-pwd1').val()).length<6){
            	layer.msg('密码不能小于6位数');
                    return false;
            }
            if($.trim($('#reg-pwd1').val()) != ''&& $.trim($('#reg-pwd1').val()).length>=6){
            	$('#register-pwd1').hide().html('');            	
            }
            
            if($.trim($('#reg-pwd2').val()) == ''){
            	layer.msg('请填写密码');
                    return false;
            }
            if($.trim($('#reg-pwd2').val()).length<6){
            	layer.msg('密码不能小于6位数');
                return false;
            }
            if($.trim($('#reg-pwd1').val())!== $.trim($('#reg-pwd2').val())){
            	layer.msg('两次密码输入不一致');
                return false;
            }
            if($.trim($('#reg-pwd2').val()) != ''&& $.trim($('#reg-pwd2').val()).length>=6){
            	$('#register-pwd2').hide().html('');            	
            }
            if($.trim($('#reg-name').val()) == ''){
            	layer.msg('请输入姓名');
				return false;
			}else{
				$('#register-name').hide().html('');
				
			}
			var tjid={$info.tjid};
			var is={$info.is};
			var data={
				username:$.trim($('#reg-phone').val()),
				code:$.trim($('#reg-code').val()),
				password:$.trim($('#reg-pwd1').val()),
				name:$.trim($('#reg-name').val()),
				tjid:tjid,
				is:is
			};
			$.post("{:url('login/registers')}",data,function(res){
				if(res.error == 0){
					layer.alert('注册成功');
					location.href="/";
				}else{
					layer.msg(res.msg);
				}
			},'json')
			//请求借口
		}
		function code(){
			var reg = /^1(3|4|5|6|7|8|9)\d{9}$/;
			if($.trim($('#reg-phone').val()) == ''){
				layer.msg('请输入手机号');
				return false;
			}						
            if(!reg.test($.trim($('#reg-phone').val()))) {
            	layer.msg('请正确填写手机号');
                 return false;
            }
            if($.trim($('#reg-phone').val()) != ''&&reg.test($.trim($('#reg-phone').val()))){
            	$('#register-phone').hide().html('');            	
            }
            
            $.ajax({
				url: basePath+"/common/send", //请求的url地址
				dataType: "json", //返回格式为json
				data:{
					access_token:md5,
					phone:$('#reg-phone').val(),
					type:'0'
				},
				type: "POST", //请求方式
				success: function(res) {
					if(res.code==0){
						layer.msg('验证码已发送！');
						$(".get-code").addClass("on");
						  var time = 60;
						  $(".get-code").attr("disabled", true);
						  var timer = setInterval(function() {
						   if (time == 0) {
						    clearInterval(timer);
						    $(".get-code").attr("disabled", false);
						    $(".get-code").html("获取验证码");
						    $(".get-code").removeClass("on");
						   } else {
						    $('.get-code').html(time + "s重新获取");
						    time--;
						   }
						  }, 1000);
					}else{
						layer.msg(res.msg);
					}
				},
				error: function(rul) {
					console.log('网络出错')
				}
			});
		}
	</script>
</html>
